package com.test.spring.rmi;

import org.junit.Test;
import org.springframework.remoting.rmi.RmiProxyFactoryBean;


public class RMIFactory {
	@Test
	public  void getRMI() {
		String url = "rmi://127.0.0.1:1199/Caculator";
		Caculator caculator = null;
		RmiProxyFactoryBean rmiProxyFactoryBean = new RmiProxyFactoryBean();
		rmiProxyFactoryBean.setServiceInterface(Caculator.class);
		rmiProxyFactoryBean.setServiceUrl(url);
		try {
			rmiProxyFactoryBean.afterPropertiesSet(); // 更改ServiceInterface或ServiceUrl之后必须调用该方法，来获取远程调用桩
		} catch (Exception ex) {
			ex.printStackTrace();
		}
		if (rmiProxyFactoryBean.getObject() instanceof Caculator)
			caculator = (Caculator) rmiProxyFactoryBean.getObject();
		float r = caculator.multiply(105235, 23);
		System.out.print(r);

	}

}
